import plugin from '../../../lib/plugins/plugin.js';
import fs from 'fs';

export class sophistry extends plugin {
  constructor () {
    super({
      name: '[Xs插件]诡辩术',
      dsc: '随机发送一张诡辩术图片',
      event: 'message',
      priority: -1919,
      rule: [
        {
          reg: "^#诡辩术$",
          fnc: 'sendImage'
        }
      ]
    })
  }

  async sendImage (e) {
    let imageDir = './plugins/Xs-plugin/resources/gbs/'; // 指定文件夹路径
    let imageFiles = fs.readdirSync(imageDir); // 读取文件夹里面的图片文件名
    let imageFile = imageFiles[Math.floor(Math.random() * imageFiles.length)]; // 随机选择一个图片文件名
    this.e.reply(segment.image(imageDir + imageFile)); // 发送图片
    return true;
  }
}	